import { ResPage } from "@/api/interface/index";
import { Flow } from "@/api/interface/workflow";
import { TICKET, BASE } from "@/api/config/servicePort";
import { ResultData } from "@/api/interface/index";
import http from "@/api";

/**
 * @name 流程配置模块
 */
// 获取流程列表
export const getFlowList = (params?: object) => {
  return http.get<ResPage<Flow.ResFlowList>>(TICKET + `/workflow/`, params); // 正常 post json 请求  ==>  application/json
};

// 创建流程
export const createFlow = (params?: object) => {
  return http.post<any>(TICKET + `/workflow/`, params); // 正常 post json 请求  ==>  application/json
};

// 修改流程
export const modifyFlow = (id: number, params: object) => {
  return http.patch<any>(`${TICKET}/workflow/${id}/`, params);
};

// 获取流程详情
export const getFlowDetail = (id: number) => {
  return http.get<any>(`${TICKET}/workflow/${id}/`);
};

// 删除流程
export const deleteFlow = (params: { ids: any[] }) => {
  return http.post(TICKET + `/workflow/multi_delete/`, params); // 正常 post json 请求  ==>  application/json
};
// 角色获取
export const getRoleList = (params?: object) => {
  return http.get<ResultData>(`${BASE}/role/`, params);
};

// 用户获取
export const getUserList = (params?: object) => {
  return http.get<ResultData>(`${BASE}/user/`, params);
};

// 业务列表获取
export const getBusinessList = (params?: object) => {
  return http.get<ResultData>(`${TICKET}/business/`, params);
};
